package com.example.onlinemusic.Config;


import com.example.onlinemusic.tools.BCryptTest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Bean
    public BCryptPasswordEncoder getBCryptPasswordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        registry.addInterceptor(loginInterceptor).
                addPathPatterns("/**")//拦截所有的URL
                .excludePathPatterns("/js/**.js")//一些要排除的资源路径
                //
                .excludePathPatterns("/images/**")
                .excludePathPatterns("/css/**.css")
                //.excludePathPatterns("/fronts/**.fnt")//???不应该是fonts嘛？？？
                .excludePathPatterns("/fonts/**.fnt")//这个好像和fronts效果一样
                .excludePathPatterns("/player/**")
                .excludePathPatterns("/login.html")
                //排除登录接口
                .excludePathPatterns("/user/login");



    }
}



